import request from '@/utils/request'

// 查询定位器设备信息列表
export function listdeviceInfo(query) {
  return request({
    url: '/business/deviceInfo/list',
    method: 'get',
    params: query
  })
}

// 查询定位器设备信息详细
export function getdeviceInfo(id) {
  return request({
    url: '/business/deviceInfo/' + id,
    method: 'get'
  })
}

// 新增定位器设备信息
export function adddeviceInfo(data) {
  return request({
    url: '/business/deviceInfo',
    method: 'post',
    data: data
  })
}

// 修改定位器设备信息
export function updatedeviceInfo(data) {
  return request({
    url: '/business/deviceInfo',
    method: 'put',
    data: data
  })
}

// 删除定位器设备信息
export function deldeviceInfo(id) {
  return request({
    url: '/business/deviceInfo/' + id,
    method: 'delete'
  })
}

// 导出定位器设备信息
export function exportdeviceInfo(query) {
  return request({
    url: '/business/deviceInfo/export',
    method: 'get',
    params: query
  })
}

// 解绑用户

export function unbind(deviceId) {
  return request({
    url: `/business/deviceInfo/unbind/${deviceId}`,
    method: 'get'
  })
}

// 设备批量换绑

export function updateBind(ids, userId) {
  return request({
    url: `/business/deviceInfo/updateBind/${ids}/${userId}`,
    method: 'get'
  })
}


// 绑定用户

export function bindMember(deviceId, memberId) {
  return request({
    url: `/business/deviceInfo/bindMember/${deviceId}/${memberId}`,
    method: 'get'
  })
}
// 用户列表

export function memberList() {
  return request({
    url: `/business/deviceInfo/memberList`,
    method: 'get'
  })
}

// 查询代理商

export function queryAgent() {
  return request({
    url: `/system/user/queryAgent`,
    method: 'get'
  })
}

// 查询设备分组角标

export function groupQuery() {
  return request({
    url: `/business/deviceInfo/groupQuery`,
    method: 'get'
  })
}

// 设备详情

export function deviceInfoDetails(deviceId) {
  return request({
    url: `/business/deviceInfo/deviceInfoDetails/${deviceId}`,
    method: 'get'
  })
}


// 设备详情

export function listByType(type, agentId, deviceNo) {
  return request({
    url: `/business/deviceInfo/listByType/${type}?agentId=${agentId ? agentId : ""}&deviceNo=${deviceNo ? deviceNo : ""}`,
    method: 'get'
  })
}


// /system/agent/currentList

export function currentList() {
  return request({
    url: `/system/agent/currentList`,
    method: 'get'
  })
}


// 异常分类统计数量

export function queryErrGroup(agentId) {
  return request({
    url: `/business/deviceErrInfo/queryErrGroup?agentId=${agentId ? agentId : ""}`,
    method: 'get'
  })
}

// 围栏可绑定设备

export function notInList(fenceId) {
  return request({
    url: `/business/deviceFenceInfo/notInList/${fenceId}`,
    method: 'get'
  })
}

// 设备批量绑定围栏

export function batchAdd(fenceId, ids) {
  return request({
    url: `/business/deviceFenceInfo/batchAdd/${fenceId}/${ids}`,
    method: 'post'
  })
}

// 查询物联网卡详情信息

export function simInfoIccid(iccid) {
  return request({
    url: `/sim/simInfo/${iccid}`,
    method: 'get'
  })
}


// 续费

export function renewBatch(data) {
  return request({
    url: `/sim/renewBatch`,
    method: 'post',
    data: data
  })
}

// 续费

export function renewBatchInfo(data) {
  return request({
    url: `/sim/renewBatchInfo`,
    method: 'post',
    data: data
  })
}

// /business/deviceBmsInfo/

export function deviceBmsInfo(batteryNo) {
  return request({
    url: `/business/deviceBmsInfo/${batteryNo}`,
    method: 'get'
  })
}

// 轨迹初始截至电量

export function powerRatio(deviceNo, startTime, endTime) {
  return request({
    url: `/business/deviceInfo/powerRatio/${deviceNo}/${startTime}/${endTime}`,
    method: 'get'
  })
}

// /business/deviceInfo/indexGroup 

export function indexGroupData() {
  return request({
    url: `/business/deviceInfo/indexGroup`,
    method: 'get'
  })
}

// 发送电池信息查询

export function sendBmsCmd(deviceNo) {
  return request({
    url: `/business/deviceBmsInfo/sendBmsCmd/${deviceNo}`,
    method: 'get'
  })
}

// 获取最新bms相关设置

export function queryBmsCmd(deviceNo) {
  return request({
    url: `/business/deviceBmsInfo/queryBmsCmd/${deviceNo}`,
    method: 'get'
  })
}

// 发送设置

export function setBmsInfo(data) {
  return request({
    url: `/business/deviceBmsInfo/setBmsInfo`,
    method: 'POST',
    data: data
  })
}

// 发送MOS,LOG指令

export function fixedCmd(deviceNo, type) {
  return request({
    url: `/business/deviceBmsInfo/fixedCmd/${deviceNo}/${type}`,
    method: 'get'
  })
}


// 透传接口

export function cmdB1(deviceNo, delayTime, cmd) {
  return request({
    url: `/business/deviceBmsInfo/cmdB1/${deviceNo}/${delayTime}/${cmd}`,
    method: 'get'
  })
}

// 播放语音

export function video(deviceNo, id, vol) {
  return request({
    url: `/business/deviceBmsInfo/video/${deviceNo}/${id}/${vol}`,
    method: 'get'
  })
}

// 设置语音

export function setVideo(deviceNo, id, url) {
  return request({
    url: `/business/deviceBmsInfo/setVideo/${deviceNo}/${id}/${url}`,
    method: 'get'
  })
}

// 查询基站信息指令

export function sendBaseCmd(deviceNo) {
  return request({
    url: `/business/deviceBmsInfo/sendBaseCmd/${deviceNo}`,
    method: 'get'
  })
}

// 获得基站信息

export function queryBase(deviceNo) {
  return request({
    url: `/business/deviceBmsInfo/queryBase/${deviceNo}`,
    method: 'get'
  })
}

// 获取超速亮屏当前值

export function queryOverSpeed(deviceNo) {
  return request({
    url: `/business/deviceBmsInfo/queryOverSpeed/${deviceNo}`,
    method: 'get'
  })
}

// 发送查询超速亮屏指令

export function sendOverSpeed(deviceNo) {
  return request({
    url: `/business/deviceBmsInfo/sendOverSpeed/${deviceNo}`,
    method: 'get'
  })
}

// 设置超速和亮屏

export function overSpeed(deviceNo, speed, time) {
  return request({
    url: `/business/deviceBmsInfo/overSpeed/${deviceNo}/${speed}/${time}`,
    method: 'get'
  })
}

// 划拨设备 /transfer/{routeId}/{deviceIds}

export function transfer(routeId, deviceIds) {
  return request({
    url: `/business/deviceInfo/transfer/${routeId}/${deviceIds}`,
    method: 'get'
  })
}

// /system/agent/getMerchantList/{id} 获取站点列表

export function getMerchantList(id) {
  return request({
    url: `/system/agent/getMerchantList/${id}`,
    method: 'get'
  })
}

// 获取划拨列表

export function getTransferList() {
  return request({
    url: `/business/deviceInfo/getTransferList`,
    method: 'get'
  })
}

export function sendCmd(deviceNo, code, data) {
  return request({
    url: `/business/deviceBmsInfo/sendCmd/${deviceNo}/${code}`,
    method: 'POST',
    data: data
  })
}